package leetcode;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.Vector;

public class LeetCodeMain81 {
    List<Integer> list=new ArrayList<>();
    public boolean isValidBST(TreeNode root) {
        if (root==null){
            return true;
        }
        inOrder(root);
        for (int i = 0; i < list.size()-1; i++) {
            if (list.get(i)>=list.get(i+1)){
                return false;
            }
        }
        return true;
    }
    public void inOrder(TreeNode root){
        if (root==null){
            return;
        }
        inOrder(root.left);
        list.add(root.val);
        inOrder(root.right);
    }
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        while (in.hasNext()){
            String str1=in.nextLine();
            String str2=in.nextLine();
            int n1=in.nextInt();
            int n2=in.nextInt();
            System.out.println(process(str1,str2,n1,n2));
        }
    }
    private static int process(String str1, String str2, int len1, int len2) {
        char[] ch1 = str1.toCharArray();
        char[] ch2 = str2.toCharArray();
        long res = 0;
        for (int i = len1; i <= len2; i++) {
            char a = ch1[0];
            char b = ch2[0];
            res += (long) Math.pow(26, i - 1) * (b - a);
            long suma = 0;
            long sumb = 0;
            for (int j = 1; j < ch1.length; j++)
            {
                suma = suma + (ch1[j] - 'a') * (long) Math.pow(26, i - 1 - j);
            }
            for (int j = 1; j < ch2.length; j++)
            {
                sumb = sumb + (ch2[j] - 'a') * (long) Math.pow(26, i - 1 - j);
            }
            res = res + sumb - suma;
        }
        res--;
        res= res % 1000007;
        return (int) res;
    }
    public static void main1(String[] args) {
        Scanner in=new Scanner(System.in);
        while (in.hasNext()){
            String str=in.nextLine();
            String[] arr=str.split(" ");
            int n1=arr[0].length();
            int n2=arr[1].length();
            int max=0;
            int[][] dp=new int[n1+1][n2+1];
            for (int i = 1; i <= n1; i++) {
                for (int j = 1; j <= n2; j++) {
                    if (arr[0].charAt(i-1)==arr[1].charAt(j-1)){
                        dp[i][j]=dp[i-1][j-1]+1;
                    }else {
                        dp[i][j]=Math.max(dp[i][j-1],dp[i-1][j]);
                    }
                    max=Math.max(dp[i][j],max);
                }
            }
            System.out.println(max);
        }
    }
}
